package com.like.dialog;


import android.text.TextUtils;
import android.view.View;

import com.bumptech.glide.Glide;
import com.like.hospitalworld.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;

@ContentView(R.layout.fragment_img_dialog)
public class ImgDialogFragment extends BaseDialogFragment {

    @ViewInject(R.id.img)
    PhotoView mImg;

    private String mUrl;

    @Override
    protected void onCreateView() {
        super.onCreateView();
        if (TextUtils.isEmpty(mUrl)) {
            dismiss();
            return;
        }
        mImg.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
            @Override
            public void onViewTap(View view, float v, float v1) {
                dismiss();
            }
        });
        Glide.with(m.mContext).load(mUrl).asBitmap().into(mImg);
    }

    public void setImgUrl(String url) {
        this.mUrl = url;
    }

    @Override
    protected void onSetPosition() {
        setPosition(MATCH_PARENT, MATCH_PARENT, DEFAULT_GRAVITY);
    }

}
